home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / MacTCP Library 1.1 / Library / LowLevel ƒ / Source ƒ / MacTCPExtras.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-04  |  1.6 KB  |  103 lines  |  [TEXT/SPM ]

  1. /*
  2.     MacTCPExtras.c
  3.     
  4.     These are extra little chunks of code needed by routines in the library.  By putting them here
  5.     they can be used by the app, too.
  6.     
  7.     01/28/94: 1.0 alpha - dn
  8.     06/01/95: 1.1 alpha - dn - Modified to use the Universal Headers.
  9.     11/28/94 mc - Converted to CodeWarrior
  10.     12/04/95 dn - Prep'd for Apprentice 4
  11. */
  12.  
  13. #include <MyTCPIncludes.h>
  14.  
  15. #include <Traps.h>
  16. #include <GestaltEqu.h>
  17. #include <Folders.h>
  18. #include <OSUtils.h>
  19. #include <Devices.h>
  20.  
  21. /*
  22.     StrLen
  23.     
  24.     A quick and dirty strlen routine.
  25. */
  26. short StrLen(char* cp){
  27.     register short i=0;
  28.     register char* c=cp;
  29.     
  30.     while (*c++)
  31.         i++;
  32.     
  33.     return i;
  34. }
  35.  
  36. /*
  37.     MyC2PStr
  38.     
  39.     A quick C --> Pascal string converter.
  40. */
  41. StringPtr MyC2PStr(char* cstr){
  42.     unsigned char len=StrLen(cstr);
  43.     
  44.     BlockMoveData((Ptr)cstr,(Ptr)(cstr+1),len);
  45.     cstr[0]=len;
  46.     
  47.     return (StringPtr)cstr;
  48. }
  49.  
  50. /*
  51.     MyP2CStr
  52.     
  53.     A quick Pascal --> C string converter.
  54. */
  55. char* MyP2CStr(StringPtr pstr){
  56.     unsigned char len=pstr[0];
  57.     
  58.     BlockMoveData((Ptr)(pstr+1),(Ptr)pstr,len);
  59.     pstr[len]=0;
  60.     
  61.     return (char*)pstr;
  62. }
  63.  
  64. /*
  65.     MemSet
  66.     
  67.     A quick and dirty memset
  68. */
  69. void MemSet(register char* c,char ch,register long size){
  70.     while (size--)
  71.         *c++=ch;
  72. }
  73.  
  74. /*
  75.     SyncAsync
  76.     
  77.     General routine for doing a synchronous or asynchronous call.  Does special error checking
  78.     to ensure that the ParmBlkPtr is not nil.
  79. */
  80. OSErr SyncAsync(ParmBlkPtr pb,Boolean async){
  81.     OSErr err;
  82.     
  83.     if (pb==(ParmBlkPtr)0)
  84.         return nilParmBlkPtr;
  85.     
  86.     if (!async){
  87.         pb->ioParam.ioCompletion=(IOCompletionUPP)0;
  88.         err=PBControlSync((ParmBlkPtr)pb);
  89.     } else {
  90.         err=PBControlAsync((ParmBlkPtr)pb);
  91.     }
  92.     
  93.     if (err==noErr)
  94.         err=pb->ioParam.ioResult;
  95.     
  96.     return err;
  97. }
  98.  
  99.  
  100.  
  101.  
  102.  
  103.